home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************************
- The purpose of this set of macros is to deal with two annoying problems
- in Brief:
-
- 1. Editing in a hex mode.
- 2. Editing "UNIX" files which use only a LF as an EOL terminator.
-
- *****************************************************************************
-
- The approach to solving the problem requires the execution of the BBE
- program. This program was written to converts a binary file into hex/ascii
- files or a "Unix" file with no CR into a standard DOS file with CR/LF EOL
- sequence depending on the flag passed. Since the program creates a hex and
- ascii file you will need at least three times the size of the original binary
- file in disk space. Make sure the bbe.exe file is in your DOS path.
-
- *****************************************************************************
- bbe.exe Usage:
- bbe [BH|HB|UD|DU] file_to_convert outfile1 {outfile2}
- Parameters:
- BH - Binary to hex
- HB - Hex to binary
- UD - Unix to Dos
- DU - Dos to Unix
-
- *****************************************************************************
- The macros:
-
- The binedit file contains two sets of macros one for hex editing and the other
- for UNIX file editing. Load this macro through your BFLAG by adding:
-
- -mbinedit
-
- I will describe the hex editing macro first since it is the most convoluted.
- And then describe the unix editing macro. Both of these macros are
- acitivated from the edit_file operation and should be transparent to the
- user. Please see the limitations/caveats at the end of this file as well as
- the comments within the macro.
- *****************************************************************************
-
- Editing Hex Files:
- This is accomplished by hooking into the language macro of brief by adding
- a package for .hex files. A registered macro is used to trap the Null
- characters fixed message and prompt for conversion. If conversion is requested,
- the bbe program is called to create a .hex and .asc file from the binary file.
- The original buffer is then deleted after it's true filename has been stored
- in the system buffer. The package buffer, which stores file extension specific
- information, is then modified to add the bin package without any specific
- BPACKAGE setting. The macro then relies on the registered macros of brief
- to process the new package setting. When the buffers are being created, the
- HEX buffer is given a .hex extension and the ASCII buffer is given the exten-
- sion of the original file.
-
- When the .hex buffer is the current buffer the _bin_on macro will be called
- which creates two windows to display the .hex and .asc files in side by side
- windows. A new keyboard is used which only assigns valid hex editing keys,
- movement keys and search keys. The current byte is highlighted in the hex
- window to display the two characters as one entity and the file offset and
- corresponding ascii character are displayed on the message line.
-
- Keyboard assignments:
- <Enter> prompts for an ascii character to overwrite the current character
- with. This will allow modification of text and do the hex conversion
- for you updating both buffers.
- <Ctrl-Enter> add a new line of bytes to the buffers
- <F10> currently assigned to execute_macro. Since you could rapidly shoot
- yourself in the foot with this, I suggest you use it with extreme
- caution.
- <Alt-n> Edit_next_buffer, the same as Brief. Changes buffers.
- <Alt-e> Edit_file
- <Alt-d> Delete a line of bytes
- <Alt-u> Undo. Since there is no undo stack for system buffers using this
- will not undo the changes to the ascii window.
- <Ctrl-u> Redo. No redo on system buffers either.
- <Alt-w> Write buffer and optionally delete the hex buffer.
- <up> Highlight the byte above the cursor.
- <left> Highlight the byte left of the cursor with scrolling.
- <right> Highlight the byte to the right with scrolling.
- <down> Highlight the byte below the cursor.
- <PgUp> Highlight the byte on previous page.
- <PgDn> Highlight the byte on the next page.
- <home> Highlight the byte at the beginning of the line.
- <end> Highlight the byte at the end of the line.
- <del> Delete the current character. Although the character is not
- physically deleted an XX byte is added which is ignored in the
- conversion process.
- <Ctrl-Pgup> Highlight the byte at the top of buffer.
- <Ctrl-PgDn> Highlight the byte at the end of the buffer.
- <F5> Perform a HEX search.
- <Alt-F5> Perform an ascii search.
- <Alt-x> Exit brief.
- <Esc> Show the corresponding ascii character for the highlighted byte.
-
- Since there is no way in brief to trap a buffer being deleted, you are forced
- to write the buffer in order to delete the associated hex and ascii files
- and do the reverse conversion. See the Limitations/Caveats for a more
- elaborate description of potential problems.
-
- There exists a macro for editing a non-binary file in hex format named
- edit_hex_file, you may at some point want to assign this macro to a key,
- if you have any free.
- *****************************************************************************
-
- Editing UNIX files: A Unix file is interpreted to be a file which has no "\n"
- on the first line of the file and has less than three lines in the file. When
- these two conditions are met, the user is prompted for execution of the bbe
- program which replaces the LF with CR/LF and creates a buffer with extension
- .unx. The macros acivate template editing for all of brief's supported
- languages with the default parameters described in the user's manual. To
- modify the parameters, change the _unx_edit macro at the end of the BINEDIT file.
- *****************************************************************************
-
- Limitations/Caveats
-
- Don't split the window with the mouse!!
-
- When exiting Brief, the prompt for modified files will not call the converter.
- Always write your changes from the editor with Alt-w.
-
- The restore macro does not interface with these macros. Attempting to restore
- your session with controlled .hex and .unx files will merely edit/create the
- requested file.
-
- These macros require the exclusive use of .hex and .unx file extensions. You
- may have problems when editing files with these file extensions. Especially
- with the write_buffer command.
-
- These macros use the original path of the file specified and create a file
- with a different extension. Files with the same name and different extensions
- cannot be edited simultaneously.
-
- When there is only one buffer and you exit Brief the macro may not delete
- the newly created files. An error message will display whenever the conversion
- is done and the files/buffers cannot be deleted.
-
- When writing buffers, you will be prompted for reconversion and buffer
- deletion. If you press ESC at any prompt the buffer will not be written. If
- you would like to continue editing respond to the prompts with "N" "N". This
- will write the buffer. When you are through editing the buffer make sure you
- respond "Y" to the delete buffer prompt. If you only have one buffer in
- memory the files will not be deleted.
-
- Be aware that deleting the hex file from the buf_list macro will not delete
- the buffer properly.
-
- Files will not be reconverted if they have not been modified.
-
- Don't do anything stupid! Although F10 is assigned in the hex edit window,
- it is there for convenience as a last resort. Avoid it like the plague.
-
- Characters cannot be inserted in the middle of the line in the hex edit
- window, they can only be changed. Only full lines can be inserted. If you
- decide to add this capability, the bbe program will not convert any XX byte.
-
- Undo/redo changes will not be reflected in the ascii buffer. The stack is
- not maintained for system buffers.
-
- If you don't care about editing binary files comment out the #define HEX.
- If you don't care about editing Unix files comment out the #define UNIX.
- Be sure to recompile afterward.
-
- Don't recompile this macro while you are in Brief. The system buffers will
- be recreated and all kinds of bizzare things will happen.
-
- This is a macro which does things which Brief was not meant to do in the
- first place. Although there is extensive error checking and as many
- different combinations as we could find were tested, you may have
- compatability problems with other macros which you have written.
-
- The Unix editing macro enables template editing with the default parameters
- for all supported languages. If you prefer smart or regular indenting, you
- will have to modify the _unx_edit macro.
-
- This set of macros took a great deal of time and testing to make them function
- as intended. They will take very little effort on your part to break them
- beyond repair. If you do not care for their implimentation.
-
-
- Good Luck,
-
- Jim Rodriguez
- Tim Hanna
- 4/1/91